package day1.how_to_create_thread_instance;
/**
 * 方法三：
 * Ⅰ.直接创建Thread对象，实现Runnable接口
 * Ⅱ.调用Thread的start方法启动该线程
 */
public class CreatThread_AchieveRunnable {
    public static void main(String[] args) {

        //以匿名内部类的方式实现Runnable接口
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.print("* ");
                }
            }
        });

        //以lamoda表达式的方式实现Runnable接口
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.print("$ ");
            }
        });

        t1.start();
        t2.start();
    }
}
